In computer systems, it is sometimes desirable to capture a portion of an image displayed on the screen of the computer's monitor. For example, the user may desire to print the captured portion of the image, or save it in a file to be electronically mailed to another person and/or subsequently processed, e.g. edited in a graphics application.
To capture a screen image, the user first designates the portion of the image to be captured, by defining a rectangular or other arbitrarily-shaped region on the screen. A screen capture routine then proceeds to obtain a data value for each display pixel within the defined region, and stores it off-screen in a suitable data structure, such as a bit map. Depending upon various factors, including the application program that generated the displayed data and various hardware specifications, the information contained within the pixel values can vary. For example, some applications may define display colors in terms of their red, green and blue components, so-called RGB values. Other applications may define colors in terms of other parameters, such as luminance and chrominence, for example. To create the off-screen pixel map, the various kinds of information are converted into a standard format. Typically, the display data is converted into an RGB format, and stored in the bit map so that each pixel is characterized by its red, green and blue components.
The data that is obtained by the screen capture routine is generated by currently active application programs that are writing data to the screen. If only one application program is active, and all of its data is presented in a single layer and/or single format, the screen capture process is quite straightforward. Basically, only one set of information needs to be accessed to determine the image that is being displayed in the designated region.
With many modern computer systems that employ a graphical user interface, however, the image data is not always displayed in a single layer. Rather, it can be displayed in multiple layers, typically in the form of windows. For example, the user interface might display a root layer which presents the metaphor of a desktop. Data displayed by one application program typically appears in a window on the desktop. For example, a word processing program might display a document within a window. If a second document is opened by the user, it is displayed in a separate window. Similarly, if the user activates a second application program, such as a communications program, its interface is displayed to the user in yet another window. The various windows can overlap one another, to present the appearance of having a stacking order where they are located at different effective distances from the viewer. Depending upon their sizes and relative locations, one window can completely obscure other windows that are below it in the stacking order, so that the lower windows are not visible to the user.
When the displayed information consists of multiple layers, for example in the form of overlapping windows, the screen capture process becomes more involved. More particularly, to gather all information regarding the displayed image, the screen capture routine must access the displayed data from each of the open windows in the designated region of the screen. Thus, in the example given above, the screen capture process obtains data from the user interface which provides the desktop metaphor, each of the two windows for the word processing documents, and the communications program interface.
In the past, a "painter's algorithm" has been employed to capture the screen display data. In essence, the algorithm iterates over each pixel of each window within the designated region of the screen, regardless of whether that pixel in the window is visible or obscured. The RGB information for the pixel is obtained, and stored in an off-screen pixel map. The algorithm proceeds recursively from the lowest layer, such as the desktop, to the topmost descendent of that layer. If four windows overlap a given screen pixel, for example, that pixel is read four times, and "painted" four times into the off-screen pixel map, i.e. once per window.
It can be appreciated that the use of the painter's algorithm to capture screen data is quite inefficient when windows overlap and obscure one another, and results in unnecessary duplication of computer system resources. It is desirable, therefore, to provide a screen capture system which eliminates unnecessary multiple reading and writing of data for display layers which are obscured by other information. In particular, it is desirable to provide a screen capture process which can quickly and efficiently eliminate data relating to obscured windows, and thereby eliminate a number of the redundant reading and writing operations inherent to screen capture processes such as those that use the painter's algorithm.